<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<link href="cartStyle.css" rel="stylesheet" type="text/javascript" />
	</head>
	<body class="cartList">
		
	    <div class="logo">
			<img src="img/dd_logo.jpg" />
			<span id="close" onclick="close_plan()">关闭</span>
			<span id="count">结算</span>

		
		    <ul>
			<li>商品图片</li>
			<li>商品信息</li>
			<li>单价</li>
			<li>数量&nbsp;&nbsp;</li>
			<li>&nbsp;&nbsp;总价</li>
			<li>操作</li>
			
			
		    </ul>
		    
		    <ul>
			<li><img id="dog" src="img/dog.jpg" /></li>
			<li>我和狗狗活下来了</li>
			<li>￥21.9</li>
			<li id="getinput">
				<input type="button" value="-" name="minus"/>
				<input type="text" name="amount"/>
				<input type="button" value="+" name="plus"/>
			</li>
			<li><input type="text" name="amount"/></li>
			<li id="num1"><p onclick="collection()">移入收藏</p>
				<p id="del1" onclick="del('del1')">删除</p>
			</li>
		    </ul>
		
		    <ul>
			<li><img id="dog" src="img/mai.jpg" /></li>
			<li>灰霾来了怎么办</li>
			<li>￥21.9</li>
			<li id="getinput">
				<input type="button" value="-" name="minus"/>
				<input type="text" name="amount"/>
				<input type="button" value="+" name="plus"/>
			</li>
			<li><input type="text" name="amount"/></li>
			<li id="num1"><p onclick="collection()">移入收藏</p>
				<p id="del2" onclick="del('del2')">删除</p></li>
		    </ul>
	    </div>
		
	</body>
	
	<script type="text/javascript">

function close_plan(){
    window.close();
}
function collection(){
    var flag=confirm("移入收藏后，将不再购物车显示，是否继续操作?");
    if(flag==true){
        alert("移入收藏成功!");
    }
}

function del(cellid){
	try{
		var flag=confirm("你确定要删除此订单？");
	var delP=document.getElementById(cellid);
	var delLi=delP.parentNode;
	var delUl=delLi.parentNode;
if(flag==true){
delUl.parentNode.removeChild(delUl);}
}catch(e){
	alert(e.message);
}


}
function minus(num){
    var prices=document.getElementsByName("price")[num].value;
    var count=parseInt(document.getElementsByName("amount")[num].value)-1;
    if(count<1){
        alert("不能再减了，再减就没有啦！");
    }
    else{
        document.getElementsByName("amount")[num].value=count;
        var totals=parseFloat(prices*count);
        document.getElementById("price"+num).innerHTML="¥" +totals;
        total();
    }
}
function plus(num){
    var prices=document.getElementsByName("price")[num].value;
    var count=parseInt(document.getElementsByName("amount")[num].value)+1;
    document.getElementsByName("amount")[num].value=count;
    var totals=parseFloat(prices*count);
    document.getElementById("price"+num).innerHTML="¥" +totals;
    total();
}
function total(){
//  var prices=document.getElementsByName("price");
    var prices=21.9;
    var count=document.getElementsByName("amount");
    var sum=0;
    for(var i=0; i<prices.length;i++){
       sum+=prices[i].value*count[i].value;
    }
    document.getElementById("totalPrice").getElementsByTagName("span")[0].innerHTML="¥" +sum;
}

		
		
	</script>
</html>
